﻿using System;

namespace BizElements.Web
{
    /// <summary>
    /// Represents a standard <see cref="SearchProvider"/> client.
    /// </summary>
    public interface ISearchClient
    {
        /// <summary>
        /// Creates a command which accepts the selected search/lookup values and sets them into the client component.
        /// </summary>
        /// <param name="calledFromPopupWindow">Indicates whether the provider is rendered in a popup/iframe window.</param>
        /// <param name="text">Command text.</param>
        /// <param name="requiredParameters">Parameters (ie. data fields) required for the accept command.</param>
        /// <returns><b>IWebCommand</b> object or <b>null</b> is the client doesn't support the accept command.</returns>
        IWebCommand CreateAcceptCommand(bool calledFromPopupWindow, string text, string[] requiredParameters);

        /// <summary>
        /// Creates a command which cancels the search/lookup action.
        /// </summary>
        /// <param name="calledFromPopupWindow">Indicates whether the provider is rendered in a popup/iframe window.</param>
        /// <param name="text">Command text.</param>
        /// <returns><b>IWebCommand</b> object or <b>null</b> if the client doesn't support the cancel command.</returns>
        IWebCommand CreateCancelCommand(bool calledFromPopupWindow, string text);

        /// <summary>
        /// Gets or sets the key under which the provider is registered.
        /// </summary>
        /// <remarks>Typically search clients use providers which are already instantiated and registered.</remarks>
        string SearchProviderKey { get; set; }
    }
}